package com.zhuojy.equity.mall.admin.service.car;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhuojy.equity.mall.admin.common.entity.po.car.TCarFuelcardPO;
import com.zhuojy.equity.mall.admin.common.pojo.ResultEntity;
import com.zhuojy.equity.mall.admin.dal.mapper.car.TCarFuelcardMapper;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author xrz
 * @version 1.0
 * @description:TODO
 * @date 2024/4/1 16:00
 */
@Slf4j
@Service
@RequiredArgsConstructor
public class TCarFuelcardServcie extends ServiceImpl<TCarFuelcardMapper,TCarFuelcardPO> {
    public ResultEntity findTCarFuelcard(TCarFuelcardPO tCarFuelcardPO, Integer pageSize, Integer pageNum) {
        Page<TCarFuelcardPO> page = new Page<>(pageNum, pageSize);
        IPage<TCarFuelcardPO> tCarPage = this.baseMapper.findTCarFuelcard(tCarFuelcardPO, page);
        return ResultEntity.OK(tCarPage);
    }

    public ResultEntity addTCarFuelcard(TCarFuelcardPO tCarFuelcardPO) {
        tCarFuelcardPO.setCreateTime(new Date());
        tCarFuelcardPO.setFuelcardUser("2");
        this.baseMapper.insert(tCarFuelcardPO);
        return ResultEntity.OK("添加成功");
    }

    public ResultEntity findTCarFuelcardByid(Integer id) {
        TCarFuelcardPO tCarFuelcardPO = this.baseMapper.selectById(id);
        return ResultEntity.OK(tCarFuelcardPO);
    }

    public ResultEntity upTCarFuelcard(TCarFuelcardPO tCarFuelcardPO) {
        int i = this.baseMapper.updateById(tCarFuelcardPO);
        return ResultEntity.OK("操作成功");
    }

    public ResultEntity delTCarFuelcard(Integer id) {
        return ResultEntity.OK(this.baseMapper.deleteById(id));
    }
}
